package org.example.java8.future;

public class FutureInAction2 {
    //block方式
    public static void main(String[] args) throws InterruptedException {
        String value = block(() -> {
            try {
                Thread.sleep(4000);
                return "I am finished.";
            } catch (InterruptedException e) {
                return "Error";
            }
        });
        System.out.println(value);
    }

    private static <T> T block(Callable<T> callable) {
        return callable.action();
    }

    private interface Callable<T> {
        T action();
    }

}
